package com.qhhc.hospital.controller;

import com.qhhc.hospital.entity.Checks;
import com.qhhc.hospital.service.IChecksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ChecksController {
    @Autowired
    IChecksService checksService;

    @RequestMapping("/insertChecks")
    public String insertChecks(@RequestBody Checks checks){
        checksService.insert(checks);
        return "success";
    }

    @RequestMapping("/getAllChecks")
    public List<Checks> getAllChecks(){
        List<Checks> checks = checksService.selectAll();
        return checks;
    }

    @RequestMapping("/getChecks/{chId}")
    public Checks getChecksById(@PathVariable("chId") Integer chId){
        return checksService.selectById(chId);
    }

    @RequestMapping("/updateChecks")
    public String updateChecks(@RequestBody Checks checks){
        checksService.update(checks);
        return "success";
    }

    @RequestMapping("/deleteChecks/{chId}")
    public String deleteChecks(@PathVariable("chId") Integer chId){
        checksService.delete(chId);
        return "success";
    }
}